#include <array>
#include <iostream>

class Solution
{
    public:
    const static int MAX = 1005;
    std::array<std::array<int,MAX>,MAX> matrix;
    void buildMatrix(int a,int b,int c, int d)
    {
      
       matrix[a][b] ++ ;
        matrix[c+1][b]--;
        matrix[a][d+1]--;
        matrix[c+1][d+1]++;
    }
    void cal(int n)
    {
        for (int i=1;i<=n;i++)
        {
            for (int j=1;j<=n;j++)
            {
                matrix[i][j] += matrix[i][j-1]+matrix[i-1][j]-matrix[i-1][j-1];
                std::cout << matrix[i][j] << " ";
            }
            std::cout << std::endl;
        }
    }
};

